@extends('admin::layouts.master')
@section('title')
    订单列表
@endsection
@section('tab')

    <div class="layui-fluid">
        <div class="layui-row">
            <form class="layui-form">
                {{csrf_field()}}
                <div class="layui-form-item">
                    <label for="username" class="layui-form-label">
                        <span class="x-red">*</span>名称</label>
                    <div class="layui-input-inline" style="width: 300px;">
                        <input type="text" id="name" placeholder="请输入标题" name="name" required="" lay-verify="required" autocomplete="off" class="layui-input"></div>
                </div>

                <div class="layui-form-item">
                    <label for="username" class="layui-form-label">
                        <span class="x-red">*</span>联系方式</label>
                    <div class="layui-input-inline" style="width: 300px;">
                        <input type="text" id="phone" placeholder="请输入联系方式" name="phone" required="" lay-verify="required" autocomplete="off" class="layui-input"></div>
                </div>

                <div class="layui-form-item">
                    <label for="username" class="layui-form-label">
                        <span class="x-red">*</span>背景颜色</label>
                    <div class="layui-input-inline" style="width: 300px;">
                        <div class="layui-input-inline" style="width: 120px;">
                            <input type="text" value="" name="color" placeholder="请选择颜色" class="layui-input" id="test-form-input">
                        </div>
                        <div class="layui-inline" style="left: -11px;">
                            <div id="test-form"></div>
                        </div>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label"><span class="x-red">*</span>类型</label>
                    <div class="layui-input-block" style="width: 300px;">
                        <select lay-filter="type" name="type">
                            <option value="">请选择活动类型</option>
                            <option value="1">2*2(正方向)</option>
                            <option value="2">2*1(长方向)</option>
                        </select>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label for="username" class="layui-form-label">
                        排序</label>
                    <div class="layui-input-inline" style="width: 300px;">
                        <input type="text" id="sort" placeholder="请输入排序" value="100" name="sort" autocomplete="off" class="layui-input"></div>
                </div>

                <div class="layui-form-item">
                    <label for="L_repass" class="layui-form-label"></label>
                    <button class="layui-btn" lay-filter="add" lay-submit="">添加</button>
                </div>
            </form>
        </div>
    </div>


@endsection

@section('tab_js')
    <script>
        layui.use(['form', 'layer', 'jquery','colorpicker'], function () {
            $ = layui.jquery;
            var form = layui.form,
                colorpicker = layui.colorpicker,
                layer = layui.layer;

            colorpicker.render({
                elem: '#test-form'
                ,color: '#1c97f5'
                ,done: function(color){
                    $('#test-form-input').val(color);
                }
            });

            var is_submit = false;
            //监听提交
            form.on('submit(add)', function (data) {
                if( is_submit ){
                    return false;
                }
                is_submit = false;
                $.ajax({
                    url: js_url('admin-road-rescue-store'),
                    type: 'post',
                    data: data.field,
                    dataType: "json",
                    success: function (result) {
                        if (result.state === 0) {
                            layer.msg(result.msg, {time: 600, icon: 6}, function () {
                                //关闭当前frame
                                xadmin.close();
                                // 可以对父窗口进行刷新
                                xadmin.father_reload();
                            });
                        } else {
                            layer.msg(result.msg, {time: 2000, icon: 5});
                        }
                    }
                });
                return false;

            });


        });
    </script>
@endsection